<?php
/**
 * 
 * $Id: AjaxExample.class.php 10 2010-04-18 21:46:44Z ccorlatti $
 * 
 */
IncludeHelper::inc('library/session/ajax/AjaxWrapper.class.php');
IncludeHelper::inc('library/session/geo/Geo.class.php');

class AjaxLocation extends AjaxWrapper {
	
	/**
	 * 
	 */
	function __construct() {
		parent::__construct();
		
		//registering ajax functions
		$this->getXAjax()->register(XAJAX_FUNCTION, array('getCountryLike', $this, 'getCountryLike') );
		
		//generates js
		$this->getXAjax()->processRequest();
		$this->setXAjaxJS($this->getXAjax()->getJavascript(XAJAX_JS_LOCATION));
		
	}
	
	
	public function getCountryLike($word, $language, $limit){
		$result = new xajaxResponse();
		try {
			$geo = new Geo();
			$countries = $geo->getCountriesLike($word, $language, $limit);
			foreach ($countries as $country){
				$html .= '<LI> ' . $country['cDescription'];
			}
			$result->assign('datos', 'innerHTML', $html);
		} catch(Exception $e){
			throw $e;
		}
		return $result;
	}
	
}

?>
